/*
 * Ext JS Library 2.2
 * Copyright(c) 2006-2008, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://extjs.com/license
 */

Ext.onReady(function(){

  //  Ext.QuickTips.init();

    // turn on validation errors beside the field globally
    Ext.form.Field.prototype.msgTarget = 'side';

	var personForm = new Ext.FormPanel({
		labelWidth:75,
		url:'save.action',
		frame:'true',
		title:'青年个人资料',
		bodyStyle:'padding:5px 5px 0',
		width:500,
		defaults:{width:230},
		defaultType:'textfield',
		standardSubmit:true,
		items:[
			{
				fieldLabel:'姓名',
				name:'person.firstName',
				allowBlank:false
			},{
				fieldLabel:'姓氏',
				name:'person.lastName',
				allowBlank:true
			}
		],
		buttons:[
			{
				text:'保存',
				handler:function(){
					if (personForm.form.isValid()) {
						
						this.disabled=true;
						personForm.form.doAction('submit',{
							url:'savePersonAction.action',
							method:'POST',
							params:'',
							waitMsg:'正在向服务器提交数据，请稍候',
							waitTitle:'提示',
							success:function(form,action){
								Ext.Msg.alert('操作','操作成功');
								this.disabled=false;
								personForm.form.reset();
								
							},
							failure:function(form,action){
								Ext.Msg.alert('操作','操作失败');
							}
						});

					}
				}
			},{
				text:'取消'
			}
		]
		
		
	});

  personForm.render(document.body);


});